package com.lqd.mall.system.service.impl;

import com.lqd.mall.interaction.system.SysOperLogEntity;
import com.lqd.mall.jpa.service.impl.BaseServiceImpl;
import com.lqd.mall.system.repository.SysOperLogRepository;
import com.lqd.mall.system.service.ISysOperLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Optional;

/**
 * @author 零起点
 * @create 2022-03-02 22:27
 */
@Service
public class SysOperLogServiceImpl
        extends BaseServiceImpl<SysOperLogRepository,SysOperLogEntity,Long>
        implements ISysOperLogService {

    @Resource
    SysOperLogRepository sysOperLogRepository;

    @Override
    public Integer save(SysOperLogEntity entity) {
         sysOperLogRepository.save(entity);
        return 1;
    }

    @Override
    public Integer deleteSysOperaLog(Long operId) {
        SysOperLogEntity entity = sysOperLogRepository.getOne(operId);
        if(entity == null){
            return 0;
        }
        Optional<Integer> integer = this.delectEntity(new SysOperLogEntity().setOperId(operId));
        return integer.get();
    }
}
